﻿using chihuopig.Service;
using chihuopig.Tool;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Net.Http;

namespace chihuopig.Consoles
{
    class Program
    {
        static void Main(string[] args)
        {

            HttpClient client = new HttpClient();
            //string code = Request.Query["code"];
            HttpResponseMessage mes =client.GetAsync($"https://api.weixin.qq.com/sns/jscode2session?appid=wx8435cbc8e761cead&secret=2fbec9c6de8e7934eb14aa07671e5b64&js_code=021ou2wo1QwwJp0wLFyo1GIVvo1ou2wd&grant_type=authorization_code").Result;
            if (mes.StatusCode == System.Net.HttpStatusCode.OK)
            {
                
                Console.WriteLine(mes.Content.ReadAsStringAsync().Result);

                Console.ReadKey();
               // context.Result = new ContentResult() { Content = mes.Content.ToString(), StatusCode = 500, ContentType = "application/json" };
            }
            //string value = UtilityHelper.DESEncrypt("10",CookieKeysCollection.Buffalo_User_Key, CookieKeysCollection.Buffalo_User_IV);

            //string name= UtilityHelper.DESDecrypt(value, CookieKeysCollection.Buffalo_User_Key, CookieKeysCollection.Buffalo_User_IV);
            // var db= DBService.getInstance("database=chihuopig;server=118.89.50.208;port=3306;user id=root;pwd=root;charset=utf8", new List<SlaveConnectionConfig>() {

            //       new SlaveConnectionConfig(){ ConnectionString="database=chihuopig;server=118.89.50.208;port=3316;user id=root;pwd=test123456;charset=utf8", HitRate=10 }
            //  });

            //var list= db.Queryable<chihuopig.Model.Admin>().ToList();
            //  db.Aop.OnLogExecuting = (sql, pars) =>
            //  {
            //      Console.WriteLine(db.Ado.Connection.ConnectionString);
            //  };
            //  long id=  db.Insertable<chihuopig.Model.Member>(new Model.Member()
            //  {
            //      Addtime=DateTime.Now,
            //      city="",
            //      headimgurl="dfds",
            //      money=0.00m,
            //      nickname="acdfsdfsd",
            //      openId="dsfdsf",
            //      Sex=1,
            //      unionid=""
            //  }).ExecuteReturnBigIdentity();

            //  db.Aop.OnLogExecuting = (sql, pars) =>
            //  {
            //      Console.WriteLine(db.Ado.Connection.ConnectionString);
            //  };
            /* using (MySql.Data.MySqlClient.MySqlConnection con = new MySql.Data.MySqlClient.MySqlConnection("database=chihuopig;server=118.89.50.208;port=3306;user id=root;pwd=root;charset=utf8"))
             {
                 con.Open();
                 //using (MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand("insert into Member(openId,headimgurl,Sex,nickname,city,unionid,money,Addtime) values('1', '1', '1', '1', '1', '1', '0.00', now()); select @@IDENTITY;", con))
                 //{
                 //    long id =Convert.ToInt64(cmd.ExecuteScalar());

                 //    //string value = UtilityHelper.DESEncrypt(CookieKeysCollection.Buffalo_User_Key, id.ToString(), CookieKeysCollection.Buffalo_User_IV);
                 //   // UtilityHelper.SetCookie(CookieKeysCollection.Buffalo_User_Key, value, DateTime.Now.AddDays(1));
                 //}



             }*/
            //db.DbFirst.Where("Member").CreateClassFile(@"F:\17素材\chihuopig\chihuopig\chihuopig.Model", "chihuopig.Model");
        }
    }
}
